package com.stadium.service.impl;

import java.util.List;
import java.util.Map;
import java.util.UUID;

import com.stadium.common.utils.SqlMapper;
import com.stadium.common.utils.UserUtils;
import com.stadium.dto.RRecruitPhotoDto;
import com.stadium.entity.RRecruitPhoto;
import com.stadium.mapper.RRecruitPhotoMP;
import com.stadium.service.RRecruitPhotoSV;
import com.stadium.vo.RRecruitPhotoVo;
import com.stadium.vo.searchVo.RRecruitPhotoSearchVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class RRecruitPhotoSVI implements RRecruitPhotoSV {
    @Autowired
    private RRecruitPhotoMP mapper;
    @Autowired
    private SqlMapper sqlMapper;

    @Override
    public List<RRecruitPhoto> queryBySQL(String sql, Map<String, Object> map) {
        return sqlMapper.selectList(sql, map, RRecruitPhoto.class);
    }

    @Override
    public void save(RRecruitPhotoVo rRecruitPhotoVo) {
        RRecruitPhoto rRecruitPhoto = new RRecruitPhoto();
        BeanUtils.copyProperties(rRecruitPhotoVo, rRecruitPhoto);
        String id = UUID.randomUUID().toString().replaceAll("-", "");
        rRecruitPhoto.setCreateUser(UserUtils.getUserId());
        rRecruitPhoto.setUpdateUser(UserUtils.getUserId());
        rRecruitPhoto.setId(id);
        mapper.save(rRecruitPhoto);
    }

    @Override
    public void update(RRecruitPhotoVo rRecruitPhotoVo) {
        RRecruitPhoto rRecruitPhoto = new RRecruitPhoto();
        BeanUtils.copyProperties(rRecruitPhotoVo, rRecruitPhoto);
        rRecruitPhoto.setUpdateUser(UserUtils.getUserId());
        mapper.update(rRecruitPhoto);
    }

    @Override
    public void saveBatch(List<RRecruitPhoto> list) {
        mapper.saveBatch(list);
    }

    @Override
    public void delete(String id) {
        mapper.delete(id);
    }

    @Override
    public void deleteBatch(String[] ids) {
        mapper.deleteBatch(ids);
    }

    @Override
    public List<RRecruitPhotoDto> query(RRecruitPhotoSearchVo searchVo) {
        return mapper.query(searchVo);
    }

    @Override
    public RRecruitPhotoDto get(String id) {
        return mapper.get(id);
    }

    @Override
    public int getCount(RRecruitPhotoSearchVo searchVo) {
        return mapper.getCount(searchVo);
    }

}
